<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24"> </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="determine" type="primary" icon="plus">确定</a-button>
      <a-button @click="cancel" type="primary" icon="plus">取消</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="info">{{ record.tiMing }}</a>
        </span>
      </a-table>
    </div>
  </a-card>
</template>

<script>
import { JeecgListMinxinPost } from '@/mixins/JeecgListMinxinPost'
import '@/assets/less/TableExpand.less'
import { correlationEdit } from '@/api/api'

export default {
  name: 'WsZhuWenShuList',
  mixins: [JeecgListMinxinPost],
  data() {
    return {
      description: '关联页面列表',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },

        {
          title: '题名',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        },
        {
          title: '文件编号',
          align: 'center',
          dataIndex: 'wenJianBianHao'
        },
        {
          title: '密级',
          align: 'center',
          dataIndex: 'miJi'
        },
        {
          title: '保管期限',
          align: 'center',
          dataIndex: 'baoCunQiXian'
        },
        {
          title: '年度',
          align: 'center',
          dataIndex: 'nianDu'
        },
        {
          title: '归档机构',
          align: 'center',
          dataIndex: 'guiDangJiGou'
        }
      ],
      url: {
        list: '/wsWenShuDangAnController/gl/queryCorrelationPageList'
      },
      dictOptions: {}
    }
  },

  created: function() {},
  methods: {
    handleTableChange(val) {
      
    },
    cancel() {
      this.$router.push({ path: '/infoList', query: { id: this.$route.query.id } })
    },
    determine() {
      
      if (this.selectedRowKeys.length > 1) {
        this.$message.info('最多一条关联数据')
        return
      }
      correlationEdit({
        guanLianBiaoShi: 1,
        guanLianZhuWenShuId: this.selectedRowKeys[0],
        zhuWenShuId: this.$route.query.id
      }).then(res => {
        if (res.success) {
          this.$router.push({ path: '/infoList', query: { id: this.$route.query.id } })
          
        }
      })
    },
    info() {
      this.$router.push({ path: '/infoList', query: { id: this.$route.query.id } })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
